from django.db import models

# Create your models here.


# 职务表
class Duty(models.Model):

    duty = models.CharField(max_length=20)

    def __str__(self):

        return self.duty


# 性别表
class Sex(models.Model):

    sex = models.CharField(max_length=5)

    def __str__(self):

        return self.sex


# 用户duty=职务，sex = 性别，name = 姓名，pswd = 登陆密码
class User(models.Model):

    duty = models.ManyToManyField(Duty)

    sex = models.ForeignKey(Sex, on_delete=models.CASCADE)

    name = models.CharField(max_length=20, unique=True)
    
    pswd = models.CharField(max_length=6,
                            default='666666',
                            )

    def __str__(self):

        return self.name

    
# 所有连接的表，url = 链接 ，duty = 权限
class Url(models.Model):

    duty = models.ManyToManyField(Duty)

    url = models.URLField()

    def __str__(self):

        return self.url

    
class Motto(models.Model):
    text = models.TextField()
    user = models.ForeignKey(User, models.PROTECT)

